package com.Yukiha.gachamod.ysm;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.List;

public class YsmAuthFolderSetup {
    private static final Logger LOGGER = LogManager.getLogger("GachaMod");
    private static final Path AUTH_BASE_PATH = Paths.get("config", "yes_steve_model", "auth");
    private static final List<String> RARITIES = List.of("common", "rare", "epic", "legendary");

    public static void ensureAuthFoldersExist() {
        try {
            // 创建主 auth 文件夹
            Files.createDirectories(AUTH_BASE_PATH);

            // 创建各稀有度子文件夹
            for (String rarity : RARITIES) {
                Path rarityPath = AUTH_BASE_PATH.resolve(rarity);
                Files.createDirectories(rarityPath);
                LOGGER.info("[GachaMod] 确保存在: " + rarityPath.toAbsolutePath());
            }

        } catch (IOException e) {
            LOGGER.error("[GachaMod] 创建授权目录失败");
            e.printStackTrace();
        }
    }

    // 可用于访问某个稀有度的路径
    public static Path getRarityPath(String rarity) {
        return AUTH_BASE_PATH.resolve(rarity.toLowerCase());
    }

    public static Path getAuthBasePath() {
        return AUTH_BASE_PATH;
    }
}
